import os
import platform


def delete_files(path):
    if os.path.exists(path):
        if os.path.isfile(path):
            delete_file(path)
        else:
            delete_folder(path)
    else:
        print("The file does not exist")


def delete_path(path):
    if os.path.exists(path):
        if os.path.isdir(path):
            delete_folder(path)
        else:
            delete_file(path)


import shutil


def delete_folder(path):
    if os.path.exists(path):
        shutil.rmtree(path)
    #     files = os.listdir(path)
    #     for file in files:
    #         file_path = path + os.sep + file
    #         print("delete_folder os.path.isdir(file_path) = " + str(os.path.isdir(file_path)))
    #         if os.path.isdir(file_path):
    #             delete_folder(file_path)
    #         else:
    #             delete_file(file_path)


def delete_file(path):
    if os.path.exists(path):
        os.remove(path)


def mkdir(path):
    if not os.path.exists(path):
        os.mkdir(path)


def open_path(path):
    system_type = platform.system()
    if system_type == "Windows":
        os.system('explorer.exe %s' % path)
    elif system_type == "Linux":
        print("请到 %s 目录下查找sf.zip文件" % path)
    elif system_type == "Darwin":
        os.system('open %s' % path)
    else:
        print("请到 %s 目录下查找sf.zip文件" % path)